{extend name="layout/layout" /}

{block name="pagecss"}
<link href="__STATIC__/admin/pages/css/order.css" rel="stylesheet" type="text/css" />
{/block}

{block name="content"}
<div class="row js-check-wrap">
    <div class="col-lg-12">
        <div class="box box-success">
            <div class="box-header with-border">
                <h3 class="box-title">配送订单详情</h3>
                <div class="box-tools pull-right">

                </div>
            </div>
            <div class="box-body">
                <!-- 基本资料 -->
                <div class="user_jbzl col-xs-12">
                    {if condition="$order.status == 1 "}
                    <h4 class="user_jbzl_head1">当前订单状态:等待买家付款</h4>
                    {elseif condition="$order.status == 2 "}
                    <h4 class="user_jbzl_head1">当前订单状态:等待卖家发货</h4>
                    {elseif condition="$order.status == 3 "}
                    <h4 class="user_jbzl_head1">当前订单状态:等待买家收货</h4>
                    {elseif condition="$order.status == 4 "}
                    <h4 class="user_jbzl_head1">当前订单状态:订单已完成</h4>
                    {elseif condition="$order.status == 9 "}
                    <h4 class="user_jbzl_head1">当前订单状态:拼团中</h4>
                    {/if}
                    <!-- <h4 class="user_jbzl_head1" case="'5'">当前订单状态:订单失效</h4> -->
                    <!-- <h4 class="user_jbzl_head1" case="'6'">当前订单状态:订单正在做售后处理</h4> -->
                </div>

                <div class="user_jbzl col-xs-12 ">
                    <!-- 基本资料 -->
                    <div class="user_jbzl">
                        <div class="">订单信息</div>
                        <div style="height: 10px"></div>
                        <div class="row fpxx">
                            <div class="col-xs-6">店铺信息：{$tenantname}</div>
                            <div class="col-xs-6">订单编号：{$order.orderNO}</div>
                            <div class="col-xs-6">下单时间：<span id="jysj1">{$order.create_time}</span></div>
                            <div class="col-xs-6">
                                付款时间：<span id="jysj">{$order.payDate}</span>
                            </div>
                            <div class="col-xs-6">
                                {if condition="$order['type'] == 0"}要求配送时间：{else /}预计取货时间：{/if}<span id="jysj2">{$order.subscribeDate}</span>
                            </div>
                        </div>

                        <div class="row fpxx">
                            {if condition="$order['status'] == 3"}
                            <div class="col-xs-6">
                                发货时间：<span>{$order.deliverDate}</span>
                            </div>
                            {/if}
                            {if condition="$order['status'] == 4"}
                            <div class="col-xs-6">
                                完成时间：<span>{notempty name="order.completedtime"} {$order.completedtime|date="Y-m-d H:i:s",###} {/notempty}</span>
                            </div>
                            {/if}
                        </div>
                        <button type="button" id="printer" orderId="{$order.id}" storeId="{$order.storeId}" class="btn">打印小票</button>
                    </div>
                </div>

                <div class="col-xs-12 ">
                    <!-- 基本资料 -->
                    <div class="user_jbzl">
                        <div class=" ">收货信息</div>
                        <div style="height: 10px"></div>
                        {if condition="$order['type'] == 0"}
                        <div class="row fpxx">
                            <div class="col-xs-6">收货人：{$order['userName']}</div>
                            <div class="col-xs-6">联系方式：{$order['userPhone']}</div>
                            <div class="col-xs-6">收货地址：{$order['deliverAddress']}</div>
                            <div class="col-xs-6">备注留言：{$order['content'] ?: '尽快收货'}</div>
                            {switch name="$order.deliverMethod"}
                                {case value="0"}<div class="col-xs-6"> 物流公司：{$order['expressName']}</div><div class="col-xs-6">物流单号：{$order['expressNo']}</div>{/case}  <!-- 物流配送 -->
                                {case value="1"}<div class="col-xs-6"> 配送方式：商家配送</div>{/case}  <!-- 商家配送 -->
                                {case value="2"}<div class="col-xs-6"> 配送方式：达达配送</div>{/case}  <!-- 达达配送 -->
                                {case value="3"}<div class="col-xs-6"> 配送方式：到店自取</div>{/case}  <!-- 到店自取 -->
                                {default /}
                            {/switch}
                            
                            <!-- <div class="col-xs-6">物流公司：{$order['expressName']}</div>
                            <div class="col-xs-6">物流单号：{$order['expressNo']}</div> -->
                        </div>
                        {elseif condition="$order['type'] == 1"/}
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;到店自取订单<br/>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;取货店铺：{$tenantname}
                        {else /}
                        {/if}
                    </div>
                </div>

                <div class="col-xs-12 user_shdz">
                    <div style="height: 10px"></div>
                    <div class="user_jbzl_head">交易信息</div>
                    <div id="table" class="row">
                        <div class="col-xs-12">
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <th width="40%">商品</th>
                                    <th width="20%">单价</th>
                                    <th width="20%">数量</th>
                                    <th width="20%">商品总价</th>
                                </tr>
                                {volist name="orderproductDetail" id="vo"}
                                <tr>
                                    <td style="display: flex; align-items: center;border: none;justify-content: center;">
                                        <img src="{$vo.productImg}" width="71px" class=" margin-right-10" />
                                        <div class="pro_de">
                                            {$vo.productName}<br/>
                                            <span style="color:#999999">{$vo.productSpec} {$vo.productSpec1?$vo.productSpec1:''} {$vo.productSpec2?$vo.productSpec2:''}  </span>
                                            <span style="color:red">
                                                <?php if(isset($vo['Refundstatus']) && $vo['Refundstatus']==4){echo '(售后中)';} ?>
                                                <?php if(isset($vo['Refundstatus']) && $vo['Refundstatus']==0){echo '(同意售后)';} ?>
                                                <?php if(isset($vo['Refundstatus']) && $vo['Refundstatus']==1){echo '(拒绝售后)';} ?>
                                                <?php if(isset($vo['Refundstatus']) && $vo['Refundstatus']==2){echo '(已退款/退货)';} ?>
                                            </span>
                                        </div>
                                    </td>
                                    <td>
                                        {$vo.price/100}元
                                    </td>
                                    <td>
                                        {$vo.count}
                                    </td>
                                    <td>
                                        {$vo.price/100 * $vo.count}元
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>

                <div class="col-xs-12 ">
                    <div  class="col-xs-3 text-right o_total">
                        优惠金额：&nbsp;{if condition="$order.oldSaleMoney"}{$order.oldSaleMoney/100}{else /}{$order.oldMemberPrice/100}{/if}元
                    </div>
                    <div  class="col-xs-3 text-right o_total">
                        配送费：&nbsp;{$order.freight / 100}元
                    </div>
                    <div  class="col-xs-3 text-right o_total">
                        包装费：&nbsp;{$order.packingfee / 100}元
                    </div>
                    <div class="col-xs-3 text-right o_total">
                        订单总金额：&nbsp;{$order.total / 100}元
                    </div>
                </div>
                <div class="col-xs-1" style="height: 30px;"></div>
                <div class="user_jbzl col-xs-12">
                    {if condition="($ispeisong && $order.type==0)"}
                    <form id="form_address_add">
                        <div class="user_jbzl_head  ">订单配送</div>
                        <input type="hidden" value="{$Distributionmode.deliverMethod}" name="deliverMethod" />
                        <input type="hidden" value="{$order.id}" name="id" />
                        <input type="hidden" value="{$order.storeId}" name="storeId" />
                        {if condition="($Distributionmode.distributionType==2 && $Distributionmode.deliverMethod==0)"}
                        <div class="row user_form_g  deliverwl">
                            <div class="col-xs-2 text-right w_b_box">
                                <span class="txt_red">*</span> <span class="txt_no">快递公司名称：</span>
                            </div>
                            <div class="col-xs-3">
                                <select name="expressName" class="form-control ">
                                    <option value="">物流公司</option>
                                    <option value="SF">顺丰快递</option>
                                    <option value="HTKY">百世快递</option>
                                    <option value="EMS">EMS</option>
                                    <option value="STO">申通快递</option>
                                    <option value="YTO">圆通快递</option>
                                    <option value="ZTO">中通快递</option>
                                    <option value="HHTT">天天快递</option>
                                    <option value="YD">韵达快递</option>
                                    <option value="DBL">德邦物流</option>
                                    <option value="ZJS">宅急送快递</option>
                                    <option value="QFKD">全峰快递</option>
                                    <option value="YZPY">邮政平邮</option>
                                    <option value="JD">京东快递</option>
                                </select>
                            </div>
                        </div>
                        <!-- 手机 -->
                        <div class="row user_form_g deliverwl">
                            <div class="col-xs-2 text-right w_b_box">
                                <span class="txt_red">*</span> <span class="txt_no">快递单号：</span>
                            </div>
                            <div class="col-xs-3">
                                <input class="form-control " type="text" name="expressNo" maxlength="35" />
                            </div>
                        </div>
                        {/if}
                        {if condition="($Distributionmode.distributionType==2 && $Distributionmode.deliverMethod==1)"}
                        <div class="row user_form_g deliverps" >
                            <div class="col-xs-2 text-right w_b_box">
                                <span class="txt_red">*</span> <span class="txt_no">配送员：</span>
                            </div>
                            <div class="col-xs-3">
                                <select name="deliverUserName" class="form-control ">
                                    <option value="">请选择</option>
                                    {volist name="staff" id="vo"}
                                    <option value="{$vo.id}">{$vo.name} + {$vo.phone}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        {/if}
                        <div class="col-xs-1" style="height: 30px;"></div>

                        <div class="form-actions">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-md-3 control-label"></label>
                                        <div class="col-md-9">
                                            <button type="button" class="btn btn-primary" id="Delivergoods">
                                                配送
                                            </button>
                                            <!--<button type="button" class="btn bg-orange" id="">-->
                                                <!--取消并退款-->
                                            <!--</button>-->
                                            <button type="button" class="btn btn-default" onclick="history.go(-1);">
                                                返回
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        {if condition="$Distributionmode==null"}
                        <div class="user_jbzl_head" style="color: red;">没有开启配送，请去设置！</div>
                        {/if}
                    </form>
                    {/if}
                </div>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="pagescript"}
<script src="__STATIC__/admin/js/include.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/order.js" type="text/javascript"></script>
<script>
    var printer_url = "{:url('admin/PrinterConsole/printsConsole')}";
    $("#printer").click(function () {
        var orderId = $(this).attr('orderId');
        var storeId = $(this).attr('storeId');
        $.ajax({
            url :printer_url,
            type : 'POST',
            dataType : 'json',
            contentType:"application/json; charset=utf-8",
            data : JSON.stringify({"orderId":orderId,"storeId":storeId,"businessId":null,"isauto":false}),
        }).done(function(data) {
            if(data.status === 0) {
                layer.msg(data.message, {icon: 5, time: 3000});
            } else if(data.status == 1){
                layer.msg(data.message, {icon: 6, time: 3000});
            }
        });

    });
</script>
{/block}